package com.ruoyi.web.controller.thesisscore;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.YcThesisScore;
import com.ruoyi.service.IYcThesisScoreService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 论文字典Controller
 * 
 * @author 杨琛
 * @date 2020-09-09
 */
@Controller
@RequestMapping("/ruoyi/thesisScore")
public class YcThesisScoreController extends BaseController
{
    private String prefix = "ruoyi/thesisScore";

    @Autowired
    private IYcThesisScoreService ycThesisScoreService;

    @RequiresPermissions("ruoyi:thesisScore:view")
    @GetMapping()
    public String thesisScore()
    {
        return prefix + "/thesisScore";
    }

    /**
     * 查询论文字典列表
     */
    @RequiresPermissions("ruoyi:thesisScore:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YcThesisScore ycThesisScore)
    {
        startPage();
        List<YcThesisScore> list = ycThesisScoreService.selectYcThesisScoreList(ycThesisScore);
        return getDataTable(list);
    }

    /**
     * 导出论文字典列表
     */
    @RequiresPermissions("ruoyi:thesisScore:export")
    @Log(title = "论文字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YcThesisScore ycThesisScore)
    {
        List<YcThesisScore> list = ycThesisScoreService.selectYcThesisScoreList(ycThesisScore);
        ExcelUtil<YcThesisScore> util = new ExcelUtil<YcThesisScore>(YcThesisScore.class);
        return util.exportExcel(list, "thesisScore");
    }

    /**
     * 新增论文字典
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存论文字典
     */
    @RequiresPermissions("ruoyi:thesisScore:add")
    @Log(title = "论文字典", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YcThesisScore ycThesisScore)
    {
        return toAjax(ycThesisScoreService.insertYcThesisScore(ycThesisScore));
    }

    /**
     * 修改论文字典
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YcThesisScore ycThesisScore = ycThesisScoreService.selectYcThesisScoreById(id);
        mmap.put("ycThesisScore", ycThesisScore);
        return prefix + "/edit";
    }

    /**
     * 修改保存论文字典
     */
    @RequiresPermissions("ruoyi:thesisScore:edit")
    @Log(title = "论文字典", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YcThesisScore ycThesisScore)
    {
        return toAjax(ycThesisScoreService.updateYcThesisScore(ycThesisScore));
    }

    /**
     * 删除论文字典
     */
    @RequiresPermissions("ruoyi:thesisScore:remove")
    @Log(title = "论文字典", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ycThesisScoreService.deleteYcThesisScoreByIds(ids));
    }
}
